class FindSumPairs {
private:
    vector<int> nums1,nums2;
    unordered_map<int,int> has;
public:
    FindSumPairs(vector<int>& nums1, vector<int>& nums2) {
        
        this->nums1=nums1;
        this->nums2=nums2;
        for(int i=0;i<nums2.size();++i){

            has[nums2[i]]++;
        }
    }
    
    void add(int index, int val) {
        
        if(index>=nums2.size()){

            return;
        }
        --has[nums2[index]];
        nums2[index]+=val;
        ++has[nums2[index]];

    }
    
    int count(int tot) {
        
        int ret=0;
        for(int i=0;i<nums1.size();++i){

            if(has.count(tot-nums1[i])){

                ret+=has[tot-nums1[i]];
            }
        }
        return ret;
    }
};

/**
 * Your FindSumPairs object will be instantiated and called as such:
 * FindSumPairs* obj = new FindSumPairs(nums1, nums2);
 * obj->add(index,val);
 * int param_2 = obj->count(tot);
 */
